package com.wit.coursesystem.dbhelper;

import android.content.Context;

import com.wit.coursesystem.dao.DaoMaster;
import com.wit.coursesystem.dao.DaoSession;
import com.wit.coursesystem.dao.DaoMaster.DevOpenHelper;

public class DbHelper {
	private static DaoMaster daoMaster;
	private static DaoSession daoSession;
	
	private DbHelper() {}

	public static DaoMaster getDaoMaster(Context context) {
		if(daoMaster == null) {
			DevOpenHelper helper = new DevOpenHelper(context, "course.db", null);
			daoMaster = new DaoMaster(helper.getWritableDatabase());
		}
		return daoMaster;
	}

	public static DaoSession getDaoSession(Context context) {
		if(daoSession == null) {
			if(daoMaster == null) {
				daoMaster = getDaoMaster(context);
			}
			
			daoSession = daoMaster.newSession();
		}
		return daoSession;
	}
	
	
}
